import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { activitiUtils } from '../../activitiUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '流程名称',
    align:"center",
    dataIndex: 'name'
   },
  {
    title: '流程标识',
    align: 'center',
    dataIndex: 'processKey',
  },
  {
    title: '版本',
    align: 'center',
    dataIndex: 'version',
    customRender:({text}) => {
      return 'v.'+text;
    },
  },
  {
    title: '所属分类',  
    align: 'center',
    dataIndex: 'categoryId',
    customRender:({text}) => {
      const color = text == '1' ? 'gray' : 'green';
      return render.renderTag(render.renderDict(text, 'bpm_process_type'), color);
    }
  },
  {
    title: '流程图片',
    align: 'center',
    dataIndex: 'id',
    customRender:activitiUtils.showResource,
  },
  {
    title: '表单路由',
    align: 'center',
    dataIndex: 'routeName_dictText',
    customRender:({text}) => {
      return render.renderDict(text, 'dict_item_status');
    }
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status',
    customRender:({text}) => {
      const color = text == '1' ? 'green' : 'gray';
      return render.renderTag(render.renderDict(text, 'dict_item_status'), color);
    },
  },
  {
    title: '备注说明',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '部署时间',
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: '更新时间',
    align: 'center',
    dataIndex: 'updateTime',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '流程名称',
    field: 'lcmc',
    component: 'Input',
  },
  {
    label: '流程标识',
    field: 'lckey',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '流程分类',
    field: 'categoryId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'bpm_process_type',
    },
  },
  {
    label: '关联表单',
    field: 'routeName',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'design_from_r,design_from_name,id',
    },
  },
  {
    label: '角色授权',
    field: 'roles',
    component: 'JSelectRole',
    componentProps: {
    },
  },
  {
    label: '排序',
    field: 'sort',
    component: 'InputNumber',
  },
  {
    label: '备注描述',
    field: 'description',
    component: 'InputTextArea',
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}